-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
patch: get select working with grouping #390
Conversation
@brookslogan does this overlap #310 work? |
Yes, this overlaps with #310, but while #310 would lend itself to something more general/proper in some cases, it's probably good to just do the mass-S3-implementation approach for now. Something for |
@dsweber2 I think the R/ folder changes still need to be pushed? |
lol, whoops. I forgot to push the new file. I was trying to separate out the patch-style methods from the proper/more permanent ones. Also, there's a ton of warnings which I don't think I caused, and the package has no styler, which means my commits may come with random formatting. Sorry about that.
Good point, I'll add some tests for this and adjust. Though the times I've actually seen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one test request. Are you planning to do more in this PR?
Also, here or in a separate PR, it'd be nice to have a |
I'd rather this not blossom into a weeks long project. I made an issue #391 for patching more generally; if any feel particularly important feel free to rearrange/add some. |
Probably remove the list from the OP so it doesn't seem like this PR is aiming to check all those boxes. |
So I added some tests for the cases you were talking about @lcbrooks, and it seems like whoever implemented |
An edge case to fix or file off: tibble::tibble(geo_value = 1, time_value = 1, age = 1, value = 1) %>%
as_epi_df(additional_metadata = list(other_keys = "age")) %>%
select(geo_value, time_value, age_group = age, value) %>%
attr("metadata")
#> $geo_type
#> [1] "hhs"
#>
#> $time_type
#> [1] "custom"
#>
#> $as_of
#> [1] "2024-01-12 16:48:48 PST"
#>
#> $other_keys
#> character(0) |
Might be a regression from |
select.epi_df <- function(.data, ...) {
selected <- NextMethod(.data)
might_decay <- reclass(selected, attr(selected, "metadata"))
return(dplyr_reconstruct(might_decay, might_decay))
}
[Hmmm, maybe the above isn't accurate. Looks like maybe I didn't account for grouped df's in select.epi_df <- function(.data, ...) {
selection <- tidyselect::eval_select(expr(c(...)), .data)
result <- .data[selection]
names(result) <- names(selection)
return (result)
} but I've opted to try to use dplyr's checks and any hidden behaviors.] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so I kind of tricked you with some pre-existing bugs and missing tests + buggy wrappers along these lines. We can't always reconstruct using the input's metadata; dplyr_reconstruct.epi_df
tries to account for things like dropped other key columns, but can't detect a rename. I think I've fixed select.epi_df
up in the rename case, along with some of the pre-existing things masking the problem, and some other stuff to make tests pass (inconsistencies between NULL
vs. character(0L)
for representing no other keys).
Please sanity-check these updates & merge.
Just confirming, |
See also @brookslogan's comment on #186 about the |
Straightforward patch of
select.epi_df
so that the grouped version doesn't drop theepi_df
type when selecting. closes #388.